/**
 * 沉浸式场景配置
 * 支持多种场景类型和3D模型集成
 */

export const SCENE_TYPES = {
    GLTF: 'gltf',           // GLTF/GLB场景文件
    GAUSSIAN_SPLAT: '3dgs',  // 3D Gaussian Splatting（已停用自研实现）
    PROCEDURAL: 'procedural', // 程序化生成场景
    HYBRID: 'hybrid',        // 混合场景（多种类型组合）
    SUPERSPLAT_VIEWER: 'supersplat' // 官方 SuperSplat Viewer 场景
};

export const IMMERSIVE_SCENES = {
    // 废弃工厂场景
    abandonedFactory: {
        id: 'abandoned-factory',
        name: '工厂2',
        type: SCENE_TYPES.GLTF,
        sceneFile: '/static/environments/class_room_2022.glb',
        characterSpawnPoint: { x: 0, y: 0, z: 0}, // VR模式下角色出现在用户正前方3米
        cameraPosition: { x: -2, y:0, z: 11},//前端界面相机的初始位置
        cameraTarget: {x: -16.766, y:-0.6, z: 7.662},//前端相机一直盯着的点
        lighting: {
            ambient: { color: 0x87CEEB, intensity: 1.5 },
            directional: { 
                color: 0xffffff, 
                intensity: 1.8,
                position: { x: 10, y: 20, z: 10 },
                castShadow: false
            }
        },
        environment: {
            fog: { color: 0x87CEEB, near: 30, far: 120 },
            background: 0x87CEEB
        },
        interactions: {
            enableGestures: true,
            enableVoiceCommands: true,
            enableGazeTracking: true
        }
    },
     libaiPoetryRealm: {
        id: 'libai-poetry-realm',
        name: '李白',
        type: SCENE_TYPES.GLTF,
        sceneFile: '/static/environments/class_room_2022.glb',
        characterSpawnPoint: { x: 0, y: 0, z: 0}, // VR模式下角色出现在用户正前方3米
        cameraPosition: { x: -2, y:0, z: 11},//前端界面相机的初始位置
        cameraTarget: {x: -16.766, y:-0.6, z: 7.662},//前端相机一直盯着的点
        lighting: {
            ambient: { color: 0xffffff, intensity: 0.6 },
            directional: { 
                color: 0xffffff, 
                intensity: 0.8,
                position: { x: 5, y: 10, z: 5 },
                castShadow: true
            }
        },
        environment: {
            fog: { color: 0x87CEEB, near: 50, far: 200 },
            background: 0x87CEEB
        },
        interactions: {
            enableGestures: true,
            enableVoiceCommands: true,
            enableGazeTracking: true,
            enableHandTracking: true
        }
    },
    // 李白3DGS诗境场景
    // libaiPoetryRealm: {
    //     id: 'libai-poetry-realm',
    //     name: '李白',
    //     type: SCENE_TYPES.SUPERSPLAT_VIEWER,
    //     sceneFile: '/static/environments/libai_3dgs.ply',
    //     characterSpawnPoint: { x: 0, y: 0, z: -2 },
    //     cameraPosition: { x: 0, y: 1.8, z: 5 },
    //     cameraTarget: { x: 0, y: 1, z: 0 },
    //     lighting: {
    //         ambient: { color: 0xffffff, intensity: 0.6 },
    //         directional: { 
    //             color: 0xffffff, 
    //             intensity: 0.8,
    //             position: { x: 5, y: 10, z: 5 },
    //             castShadow: true
    //         }
    //     },
    //     environment: {
    //         fog: { color: 0x87CEEB, near: 50, far: 200 },
    //         background: 0x87CEEB
    //     },
    //     interactions: {
    //         enableGestures: true,
    //         enableVoiceCommands: true,
    //         enableGazeTracking: true,
    //         enableHandTracking: true
    //     }
    // },

    // 杜甫校园场景（GLTF）
    dufuSchoolCampus: {
        id: 'dufu-school',
        name: '杜甫',
        type: SCENE_TYPES.GLTF,
        sceneFile: '/static/environments/school.glb',
        characterSpawnPoint: { x: 0, y: 0, z: -3 },
        cameraPosition: { x: 0, y: 1.8, z: 7.5 },
        cameraTarget: { x: 0, y: 1.2, z: 0 },
        lighting: {
            ambient: { color: 0xffffff, intensity: 0.6 },
            directional: {
                color: 0xffffff,
                intensity: 1.2,
                position: { x: 10, y: 20, z: 10 },
                castShadow: true
            }
        },
        environment: {
            background: 0x87CEEB,
            fog: { color: 0x87CEEB, near: 50, far: 180 }
        },
        interactions: {
            enableGestures: true,
            enableVoiceCommands: true,
            enableGazeTracking: true
        }
        },

    // 杜甫校园场景（GLTF）
    sushiSchoolCampus: {
        id: 'sushi-school',
        name: '苏轼',
        type: SCENE_TYPES.GLTF,
        sceneFile: '/static/environments/class_room_2022.glb',
        characterSpawnPoint: { x: 0, y: 0, z: -3 },
        cameraPosition: { x: 0, y: 1.8, z: 7.5 },
        cameraTarget: { x: 0, y: 1.2, z: 0 },
        lighting: {
            ambient: { color: 0xffffff, intensity: 0.6 },
            directional: {
                color: 0xffffff,
                intensity: 1.2,
                position: { x: 10, y: 20, z: 10 },
                castShadow: true
            }
        },
        environment: {
            background: 0x87CEEB,
            fog: { color: 0x87CEEB, near: 50, far: 180 }
        },
        interactions: {
            enableGestures: true,
            enableVoiceCommands: true,
            enableGazeTracking: true
        }
    }
};

// 诗人与场景的关联配置
export const POET_SCENE_MAPPING = {
    'li-qingzhao': 'abandonedFactory',
    'liqingzhao': 'abandonedFactory',
    'li-bai': 'libaiPoetryRealm',
    'libai': 'libaiPoetryRealm',
    'li-taibai': 'libaiPoetryRealm',
    'dufu': 'dufuSchoolCampus',
    'du-fu': 'dufuSchoolCampus',
    'sushi': 'sushiSchoolCampus',
    'su-shi': 'sushiSchoolCampus'
};


// 默认场景配置
export const DEFAULT_SCENE = 'abandonedFactory';

/**
 * 获取场景配置
 * @param {string} sceneId - 场景ID
 * @returns {Object|null} 场景配置对象
 */
export function getSceneConfig(sceneId) {
    return IMMERSIVE_SCENES[sceneId] || null;
}

/**
 * 获取诗人推荐场景
 * @param {string} poetId - 诗人ID
 * @returns {Array} 推荐场景ID列表
 */
export function getPoetRecommendedScenes(poetId) {
    const mappedScene = POET_SCENE_MAPPING[poetId];
    return mappedScene ? [mappedScene] : [DEFAULT_SCENE];
}

/**
 * 获取所有可用场景
 * @returns {Array} 场景配置列表
 */
export function getAllScenes() {
    return Object.values(IMMERSIVE_SCENES);
}

/**
 * 根据类型筛选场景
 * @param {string} type - 场景类型
 * @returns {Array} 筛选后的场景列表
 */
export function getScenesByType(type) {
    return Object.values(IMMERSIVE_SCENES).filter(scene => scene.type === type);
}